package com.lsh.payment.core.model.refund;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.lsh.payment.core.model.BaseVender;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.apache.commons.lang.StringUtils;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

/**
 * @author peter
 */
@Setter
@Getter
@NoArgsConstructor
public class PayRefund extends BaseVender implements Serializable {
    private static final long serialVersionUID = 1300512745287031776L;
    private Long id;

    private String paymentRefundNo;

    private String refundTradeId;

    private String payPaymentNo;

    private String channelRefundId;

    private BigDecimal refundAmount;

    private String refundChannel;

    private String amountType;

    private String refundRecvAccout;

    private Date createAt;

    private Date updateAt;

    private Date refundAt;

    private Integer isValid;

    private Integer refundStatus;

    private Integer callSystem;

    private String ext;

    private String refundNotifyUrl;

    //初始化 ext
    private Integer refund_type;

    private String notify_ext;


    public void init() {

        if (StringUtils.isBlank(this.ext)) {

            return;
        }
        JSONObject ext = JSON.parseObject(this.getExt());

        this.setRefund_type(ext.getInteger("refund_type"));
        this.setNotify_ext(ext.getString("notify_ext"));
    }
}